package com.sinosoft.vaccinetoai.server.business.chatrecord.addchatrecord.service.impl;

import com.sinosoft.vaccinetoai.dao.mapper.business.ChatRecordMapper;
import com.sinosoft.vaccinetoai.dao.po.business.ChatRecord;
import com.sinosoft.vaccinetoai.server.business.chatrecord.addchatrecord.io.AddChatRecordListIO;
import com.sinosoft.vaccinetoai.server.business.chatrecord.coverter.ChatRecordConverter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import com.sinosoft.vaccinetoai.server.business.chatrecord.addchatrecord.vo.AddChatRecordVO;
import com.sinosoft.vaccinetoai.server.business.chatrecord.addchatrecord.service.IAddChatRecordService;

import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @ClassName: AddChatRecordServiceImpl
 * @ClassNameExplain: 
 * @Description: 新增聊天记录Service Impl
 * @author xiazhihao
 * @date 2023年12月18日 21:49
 */
@Slf4j
@Service("AddChatRecordService")
public class AddChatRecordServiceImpl implements IAddChatRecordService {

	@Resource
	private ChatRecordMapper chatRecordMapper;

	@Override
	public AddChatRecordVO addChatRecord(AddChatRecordListIO io) throws Exception {
        AddChatRecordVO vo = new AddChatRecordVO();
		List<ChatRecord> chatRecords = ChatRecordConverter.covertChatRecords(io.getAddChatRecordIOList());
		chatRecordMapper.batchSave(chatRecords);
		List<Long> ids = chatRecords.stream().map(ChatRecord::getId).collect(Collectors.toList());
		vo.setIds(ids);
		return vo;
	}
	
}